<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
 * @license    GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport('joomla.application.component.controller');
 
/**
 * Hello World Component Controller
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class wotclanController extends JController
{
    /**
     * Method to display the view
     *
     * @access    public
     */
    function display()
    {
        parent::display();
    }
	/**
	* Method to call the edit form
	*/
	function edit()
	{
		JRequest::setVar( 'layout', 'form' );
		parent::display();
	}

	/**
	* Method to get the data from the form and let the model save it
	*/
	function save()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// get the model
		$model =& $this->getModel();
 
		//get data from request
		$post = JRequest::get('post');
		$post['content'] = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW);
 
		// let the model save it
		if ($model->store($post)) {
			$message = JText::_('Success');
		} else {
			$message = JText::_('Error while saving');
			$message .= ' ['.$model->getError().'] ';
		}
		$this->setRedirect('index.php?option=com_wotcal', $message);
	}

	/**
	* Cancel, redirect to component
	*/
	function cancel()
	{
		$this->setRedirect('index.php?option=com_wotcal');
	}
 
}
